// {
//   "code": 200,
//   "msg": "成功",
//   "data": {
//     "id": 1,
//     "title": "如何高效学习编程？这 5 个方法你一定要知道",
//     "content": "<p>在当今数字化时代，编程已成为一项核心技能。本文将分享五种高效学习编程的方法...</p>",
//     "excerpt": "掌握高效学习方法，让你的编程之路事半功倍。",
//     "coverImage": "https://picsum.photos/800/400?random=1",
//     "author": "李明",
//     "categoryId": 1,
//     "views": 14,
//     "createdAt": "2025-10-28T02:35:09.000Z",
//     "updatedAt": "2025-10-28T06:38:34.000Z",
//     "isDeleted": false,
//     "deletedAt": null,
//     "Category": {
//       "id": 1,
//       "name": "推荐"
//     },
//     "Comments": [
//       {
//         "id": 1,
//         "targetId": 1,
//         "userId": 1,
//         "parentId": 0,
//         "content": "笑死我了",
//         "status": true,
//         "createdAt": "2025-10-28T04:54:11.000Z",
//         "updatedAt": "2025-10-28T06:42:35.000Z",
//         "isDeleted": false,
//         "deletedAt": null,
//         "User": {
//           "id": 1,
//           "username": "ikun",
//           "nickname": "坤坤",
//           "avatar": "https://api.dicebear.com/9.x/lorelei/svg?seed=1761559449589"
//         }
//       }
//     ]
//   }

import { ApiProperty } from "@nestjs/swagger";

import { ArticleEntity } from "../entities/article.entity";

class CategoryVO {
    @ApiProperty()
    id: number;
    @ApiProperty()
    name: string;
}

class UserVO {
    @ApiProperty()
    id: number;
    @ApiProperty()
    username: string;
    @ApiProperty()
    nickname: string;
    @ApiProperty()
    avatar: string;
}

class CommentVO {
    @ApiProperty()
    id: number;
    @ApiProperty()
    targetId: number;
    @ApiProperty()
    userId: number;
    @ApiProperty()
    parentId: number;
    @ApiProperty()
    content: string;
    @ApiProperty()
    status: boolean;
    @ApiProperty()
    createdAt: Date;
    @ApiProperty()
    updatedAt: Date;
    @ApiProperty()
    isDeleted: boolean;
    @ApiProperty()
    deletedAt: Date;
    @ApiProperty({ type: () => UserVO })
    User: UserVO;
}

export class ArticleDetailVO extends ArticleEntity {
    @ApiProperty({ type: () => CategoryVO }) // 嵌套类型，并且使用箭头函数 () => CategoryVO延迟解析类型，避免循环引用
    Category: CategoryVO;
    @ApiProperty({ type: () => CommentVO, isArray: true })
    Comments: CommentVO[];
}
